package com.baizhi.genericity2;

import java.util.Random;

/**
 * 福利彩票
 */
public class Welfare implements GenNumUtil<String> {

    //写一个方法生成一个数组，数组中包含a-z所有字符
    public char[] getStrArr(){
        char[] ch = new char[26];
        for (int i = 97, j = 0; i < 123; i++,j++) {
            ch[j] = (char)i;
        }
        return ch;
    }

    @Override
    public String genNum() {
        //定义一个可以选用的char类型的数据
        char[] chs = getStrArr();
        String code = "";
        for (int i = 0; i < 5; i++) {
            Random ran = new Random();
            int m = ran.nextInt(chs.length);
            char ch = chs[m];
            code += ch;
        }
        return code;
    }
}


